<%@page import="cn.lily.com.enviroment.Enviroment"%>
<%@page import="app.portal.util.EnumValue"%>
<%@page import="cn.lily.com.db.sql.DBManager"%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@page import="cn.lily.com.db.DBFactory"%>
<%@page import="cn.lily.com.db.container.reader.DataTable"%>
<%@ page import="cn.lily.inst.web.frames.FrameConfig" %>
<%@ page import="cn.lily.web.util.context.WebContext" %>
<%@ page import="cn.lily.esb.context.AuthEntity" %>
<%@ page import="cn.lily.com.configure.util.ESBSetting"%>
<%@ include file="/frames/logbegin.jsp" %>
<%
	
	response.addHeader("Cache-Control", "no-store");
	response.addHeader("Pragma", "no-cache");

	String skinName = "";
	String contextPath ="";
	AuthEntity authEntity = (AuthEntity) session.getAttribute(WebContext.LOG_AUTH_CONTEXT);
	if (authEntity != null) {
		skinName      = authEntity.getSkinName();
		contextPath = authEntity.getContextPath();
	}
	FrameConfig.setContextPath(contextPath);
	DBManager dbManager=DBFactory.getActionDB();
	String sql="";
	//管理员:显示管理应用
	if(EnumValue.OPER_TYP_1.equals(authEntity.getOperEntity().getOperType())){
		if(EnumValue.COMM_TYP_0.equals(authEntity.getOperEntity().getCommEntity().getCommTyp())) {
  			 sql =" SELECT count(1)AS count FROM ${schema}.pw_app_detail ai RIGHT JOIN ${schema}.PW_APP_VER_PUBLISH avp ON ai.pw_app_id=avp.pw_app_id "+
  	  			  " WHERE  ai.app_sta='"+EnumValue.APP_STA_1+
  	  			  "' and avp.apptype IN ('"+EnumValue.APPTYPE_0+"','"+EnumValue.APPTYPE_1+"','"+EnumValue.APPTYPE_4+"') "+
  	  			  "and (ai.link_typ in('"+EnumValue.LINK_TYP_0+"','"+EnumValue.LINK_TYP_2+"') or (ai.link_typ="+EnumValue.LINK_TYP_1+
	  			  " and EXISTS ( select 1 from ${schema}.pw_app_oper where pw_app_id=ai.pw_app_id and OPER_KEY='"+authEntity.getOperatorId()+"')))";
  		}else if(EnumValue.COMM_TYP_1.equals(authEntity.getOperEntity().getCommEntity().getCommTyp())) {
  			 sql =" SELECT count(1)AS count FROM ${schema}.pw_app_detail ai RIGHT JOIN PW_APP_VER_PUBLISH avp ON ai.pw_app_id=avp.pw_app_id "+
  	  			  " WHERE ai.app_sta='"+EnumValue.APP_STA_1+
  	  			  "' and ((avp.apptype in ('"+EnumValue.APPTYPE_0+"','"+EnumValue.APPTYPE_2+"','"+EnumValue.APPTYPE_4+"') "+
 				  " and avp.trad_typ='"+authEntity.getOperEntity().getCommEntity().getTradTyp()+"') or ai.pw_app_id in('000078','000070'))"+
  	  			  " and (ai.link_typ in('"+EnumValue.LINK_TYP_0+"','"+EnumValue.LINK_TYP_2+"') or (ai.link_typ="+EnumValue.LINK_TYP_1+
	  				  " and EXISTS ( select 1 from ${schema}.pw_app_oper where pw_app_id=ai.pw_app_id and OPER_KEY='"+authEntity.getOperatorId()+"'))) ";
  		}else{
  			sql =" SELECT count(1)AS count FROM ${schema}.pw_app_detail ai RIGHT JOIN PW_APP_VER_PUBLISH avp ON ai.pw_app_id=avp.pw_app_id "+
  	  			 " WHERE ai.app_sta='"+EnumValue.APP_STA_1+
  	  			 "' and (((avp.apptype IN ('"+EnumValue.APPTYPE_0+"','"+EnumValue.APPTYPE_4+"')"+
 				 " or (avp.apptype='"+EnumValue.APPTYPE_3+"' and avp.comm_lev >='"+ authEntity.getOperEntity().getCommEntity().getCommLev()+"'))"+
 				 " and avp.trad_typ='"+authEntity.getOperEntity().getCommEntity().getTradTyp()+ "') or ai.pw_app_id='000078') "+
 				 " and (ai.link_typ in('"+EnumValue.LINK_TYP_0+"','"+EnumValue.LINK_TYP_2+"') or (ai.link_typ="+EnumValue.LINK_TYP_1+
  				  " and EXISTS ( select 1 from ${schema}.pw_app_oper where pw_app_id=ai.pw_app_id and OPER_KEY='"+authEntity.getOperatorId()+"'))) ";
  		}
	//员工:显示被授权应用	  
   }else{
   sql="select count(1) as count from (select DISTINCT ai.pw_app_id,ai.app_nam,ai.sign_ico,ai.apps_des,ai.oper_tim,ai.SYS_TYP,di.TYP_NAM "+
		  	" from ${schema}.PW_APP_DETAIL ai RIGHT JOIN ${schema}.PW_APP_VER_PUBLISH bi ON ai.pw_app_id=bi.pw_app_id LEFT JOIN ${schema}.PT_SYS_TYPE di ON ai.sys_typ=di.sys_typ "+
	  		" where ai.app_sta='"+EnumValue.APP_STA_1+"' and ai.pw_app_id in "+
		  	" ((select y.pw_app_id from ${schema}.PW_ROLE_RES x,${schema}.pw_app_model y where x.mode_id=y.mode_id and x.role_id in (select role_id from ${schema}.pw_oper_role where oper_key='"+authEntity.getOperatorId()+"') "+
	  		" union select pw_app_id from ${schema}.PW_APP_OPER where oper_key='"+authEntity.getOperatorId()+"')))";
   }
	DataTable appTable=dbManager.executeQueryTable(sql);
	appTable.next();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title><%=FrameConfig.getAppName()%></title>
  <link href="/<%=ESBSetting.getString("appCode")%>/public/style/skin_bootstrap/bootstrap-3.3.0/bootstrap.css" rel="stylesheet" media="screen">
  <link href="/<%=ESBSetting.getString("appCode")%>/public/font/awesome/font-awesome-4.7.0.css" rel="stylesheet">
  <link href="<%=FrameConfig.getCSSPath("app.css") %>" rel="stylesheet" />
</head>
<body>
  <!-- <div id="main-left" style="display: none;"> -->
  <div id="main-left">
    <ul class="menu-list">
      <li><i style="color:#3498DB;" class="fa fa-user"></i>我的应用(<%=appTable.getString("count")%>)</li>
    </ul>
    <div class="menu-line"></div>
    <ul class="menu-list">
      <li><i style="color:#E67E22;" class="fa fa-thumbs-o-up"></i>应用推荐</li>
      <li><i style="color:#9B59B6;" class="fa fa-shopping-cart"></i>应用商店</li>
    </ul>
    <div class="menu-line"></div>
    <ul class="menu-list">
      <li><i style="color:#5DA5D5;" class="fa fa-bar-chart-o"></i>效率</li>
      <li><i style="color:#C7332E;" class="fa fa-cog"></i>工具</li>
      <li><i style="color:#53A93F;" class="fa fa-comment"></i>沟通</li>
      <li><i style="color:#EDAF00;" class="fa fa-quote-left"></i>咨询</li>
      <li><i style="color:#1D71A9;" class="fa fa-smile-o"></i>娱乐</li>
      <li><i style="color:#D20A0A;" class="fa fa-heart"></i>分享</li>
      <li><i style="color:#1D9E66;" class="fa fa-puzzle-piece"></i>游戏</li>
    </ul>
    <div class="menu-line"></div>
  </div>
  <div id="main-right">
    <iframe id="mainiframe" src="applist.jsp" frameborder="0" scrolling="no" height="99%" width="100%"></iframe>
  </div>

  <script src="<%=FrameConfig.getBaseJsUrl() %>/common/jquery-1.9.1.min.js"></script>
  <script src="/<%=ESBSetting.getString("appCode")%>/public/js/skin_bootstrap/bootstrap-3.3.0/bootstrap-3.3.0.js"></script>
  <script src="<%=FrameConfig.getJsUrl("app.js")%>"></script>
  <script type="text/javascript">
  $(function() {
		//设置高度
		var wid=$(window).width();
		var hei=$(window).height();
		var widLeft=$("#main-left").width();
		var widFrame=parseInt(wid-widLeft);
		//alert(widFrame);
		//$("#mainframe").width(wid);
		//$("#mainframe").height(hei);		
	});
  </script>
</body>
</html>
<%
	dbManager.free();
%>
<%@ include file="/frames/logend.jsp" %>


